#pragma once
/* Copyright (C) 2009 Vlad Roubtsov. All rights reserved. */

#include "vr/deject/initializable.hpp"
#include "vr/deject/startable.hpp"
#include "vr/deject/types.hpp"
#include "vr/util/utility.hpp"

//----------------------------------------------------------------------------
namespace vr
{
namespace deject
{
/**
 *
 */
class component_base: noncopyable
{
    public: // ...............................................................

        virtual ~component_base () {}


        const component_id_type & ID () const
        {
            return m_ID;
        }

    protected: //.............................................................

        component_base (const bool /* unused */, const component_id_type & ID) :
            m_ID (ID)
        {
        }

    private: // ..............................................................

        const component_id_type m_ID;

}; // end of class


template<typename Derived>
class component: public component_base
{
    public: // ...............................................................

        typedef component<Derived> super;

    protected: //.............................................................

        component (const component_id_type & ID) :
            component_base (s_register, ID) // dummy use of 's_register' to trigger template instatiation without "unused var" warnings
        {
        }


    private: // ..............................................................

        static bool s_register;

}; // end of class

template<typename Derived>
bool component<Derived>::s_register = Derived::register_class ();

} // end of 'deject'
} // end of namespace
//----------------------------------------------------------------------------
